﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;

namespace 养老金支付系统
{
    public partial class FormPrintView : FormBase
    {
        /// <summary>
        /// 指定数据源名称
        /// </summary>
        public string ReportDataSetName { get; set; }
        /// <summary>
        /// 报表的参数
        /// </summary>
        public ReportParameter[] ReportParam { get; set; }
        /// <summary>
        /// 绑定的数据源
        /// </summary>
        public object DataSources { get; set; }
        /// <summary>
        /// 指定报表文件
        /// </summary>
        public string ReportPath { get; set; }

        public FormPrintView()

        {
            InitializeComponent();
        }

        private void FormPrintView_Load(object sender, EventArgs e)
        {
            this.reportViewer1.LocalReport.DataSources.Clear();
            this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource(this.ReportDataSetName, this.DataSources));
            this.reportViewer1.LocalReport.ReportPath = this.ReportPath;

            //this.reportViewer1.RefreshReport();

            //this.reportViewer1.LocalReport.ReportEmbeddedResource = this.ReportPath;
            
            if (this.ReportParam != null)
                this.reportViewer1.LocalReport.SetParameters(this.ReportParam);
            
            //设置打印布局模式,显示物理页面大小
            this.reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
            //缩放模式为百分比,以100%方式显示
            this.reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent;
            this.reportViewer1.ZoomPercent = 100;
            //this.reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.PageWidth;
            
            this.reportViewer1.RefreshReport();
        }
    }
}
